﻿using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Gadgeteer.Interfaces.Fakes.Tests
{
    [TestFixture]
    public class FakeCameraTest
    {
        [Test]
        public void GetPicture()
        {
            var camera = new FakeCamera();
            Picture picReceived = null;
            camera.PictureCaptured += (s, picture) =>
                {
                    picReceived = picture;
                };

            camera.TakePicture();
            Thread.Sleep(500);

            Assert.That(picReceived, Is.Not.Null);
        }

        public void GetTwoPictures()
        {
            var camera = new FakeCamera();
            Picture lastPicture = null;
            camera.PictureCaptured += (s, picture) =>
            {
                lastPicture = picture;
            };

            camera.TakePicture();
            Thread.Sleep(300);
            Assert.That(lastPicture, Is.Not.Null);
            Picture pic1 = lastPicture;

            camera.TakePicture();
            Thread.Sleep(300);

            Assert.That(lastPicture, Is.Not.Null);
            Assert.That(pic1, Is.Not.EqualTo(lastPicture));
        }

        void camera_PictureCaptured(ICamera sender, Picture picture)
        {
            throw new NotImplementedException();
        }
    }
}
